<?php
/*******************************************************************************
 * $Date:: Jan 11, 2011 10:28:10 AM											   $
 * $Revision: 													               $
 * $Author:: Tuan Duong													       $
 * $Comment::															       $
 ******************************************************************************/ 

/**
 * Class description.
 * @package: Lua
 * @subpackage: Subpackage
 * @author: Tuan Duong
 * @version: 
 */
 
abstract class Lua_Test_TestCase extends PHPUnit_Framework_TestCase
{
    protected function setUp()
    {
        parent::setUp();
        Lua_Service_Locator::getInstance()->resetServices();
        Zend_Db_Table::getDefaultAdapter()->beginTransaction();
    }

    protected function tearDown()
    {
        Zend_Db_Table::getDefaultAdapter()->rollBack();
        parent::tearDown();
    }

    protected function getStub($originalClassName)
    {
        return $this->getMock($originalClassName, array(), array(), '', false, false);
    }

    /**
     * @param string $name name should be Pascal case without namespace,
     *   e.g 'User', 'Business' for Lua_Service_User and Lua_Service_Business
     * @return Lua_Service_Interface
     */
    protected function getServiceMock($name)
    {
        $className = 'Lua_Service_' . $name;
        $serviceMock = $this->getStub($className);
        Lua_Service_Locator::getInstance()->setService($name, $serviceMock);

        return $serviceMock;
    }

}
